package com.codi.bus.core.sys.service.impl;

import com.codi.base.api.result.PageResult;
import com.codi.base.domain.BaseResult;
import com.codi.bus.core.sys.dao.OrganFileDao;
import com.codi.bus.core.sys.domain.OrgFile;
import com.codi.bus.core.sys.service.OrganFileService;
import com.codi.bus.core.sys.vo.OrgFileVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

/**
 * Created by wangzhenhao on 2017/9/19.
 */
@Service
public class OrganFileServiceImpl implements OrganFileService {
    @Autowired
    private OrganFileDao organFileDao;

    @Override
    public BaseResult queryList(Pageable pageReq) {
        Page<OrgFileVo> orgFiles = organFileDao.query(pageReq);

        return new PageResult<>(orgFiles);
    }

    @Override
    public BaseResult search(Pageable pageReq, String content) {
        Page<OrgFileVo> orgFiles = organFileDao.search(pageReq, content);

        return new PageResult<>(orgFiles);
    }

    @Override
    public BaseResult getFileInfoByFileId(Long fileId) {
        return BaseResult.success(organFileDao.selectByPrimaryKey(fileId));
    }

    @Override
    public BaseResult updateFileInfo(OrgFile orgFile) {
        return BaseResult.success(organFileDao.updateByPrimaryKey(orgFile));
    }
}
